package cn.agiledata.bank.myspace.service;

import java.lang.reflect.Method;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.aop.AfterReturningAdvice;

import cn.agiledata.bank.hibernateBean.Account;
import cn.agiledata.bank.hibernateBean.AccountHis;
import cn.agiledata.bank.common.dao.AccountTemplateInter;

public class AccountHisInterceptor implements AfterReturningAdvice  {
	private AccountTemplateInter at;
	
	public AccountTemplateInter getAt() {
		return at;
	}
	
	public void setAt(AccountTemplateInter at) {
		this.at = at;
	}
	
	public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
		// TODO Auto-generated method stub
		Account account = (Account)args[0]; //得到修改后的账户对象
		AccountHis accountHis = new AccountHis();
		BeanUtils.copyProperties(accountHis,account); //把账户对象转换成账户历史对象
		accountHis.setId(null);
		accountHis.setCardPhoto(null);
		accountHis.setPhoto(null);
		accountHis.setCardPhotoBack(null);
		accountHis.setTempCardPhoto(null);
		accountHis.setTempCardPhotoBack(null);
		getAt().saveHisAccount(accountHis); //保存账户历史对象
	}






}
